package com.amigo.online.message.util;

import com.alibaba.fastjson.JSON;
import com.amigo.online.common.param.dto.group.NewGroupDto;
import com.amigo.online.message.mybatisbean.GroupTbl;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class BeanUtil {

    /**
     * 对象转换(只要值相同就能转)
     * @param old
     * @param n
     * @param <T>
     * @return
     */
    public static <T> T transformation(Object old, Class<T> n){
        return JSON.parseObject(JSON.toJSONString(old), n);
    }
    public static void main(String[] args) {
        System.out.println(new Date().getTime()/1000);
        NewGroupDto groupDto = new NewGroupDto();

        List<Long> memberIds = new ArrayList();
        memberIds.add(1111111111111111l);
        memberIds.add(2222222222222222l);

        groupDto.setMemberIds(memberIds);
        groupDto.setName("name");
        groupDto.setAddress("avatar");
        groupDto.setLongitude("longitude");
        groupDto.setLatitude("latitude");
        groupDto.setExamine(1);
        groupDto.setAddress("asd");
        groupDto.setAddress("asd");
        groupDto.setAddress("asd");
        GroupTbl groupTbl = new GroupTbl();
        groupTbl = BeanUtil.transformation(groupDto, groupTbl.getClass());
        System.out.println(JSON.toJSONString(groupTbl));

    }
}
